import {ControlType, FormBase} from './form-base';

export class FormDate extends FormBase<any> {
    controlType: ControlType = 'date';
    private _value: any = null;
    get value() {
        return this._value;
    }

    set value(date: any) {
        if (date) {
            if (typeof date === 'string') {
                this._value = new Date(Number(date));
            } else if (typeof date === 'number') {
                this._value = new Date(date);
            } else {
                console.error(`FormData类的属性value的数据类型只能为string or number`);
                console.error(`当前的数据类型是:${typeof date},请检查`);
            }
        }
    }

    constructor(options: {} = {}) {
        super(options);
        this.value = options['value'];
    }
}
